// StiLibMng.h: interface for the CStiLibMng class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_STILIBMNG_H__1658B213_82DF_4445_9D03_572FA6C3602C__INCLUDED_)
#define AFX_STILIBMNG_H__1658B213_82DF_4445_9D03_572FA6C3602C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "StiLib.h"
#include <afxtempl.h>

class CStiLibMng : public CObject  
{
	CStiLibMng();
	virtual ~CStiLibMng();
public:
	static CStiLibMng* instance()
	{
		if (_instance == NULL)
		{
			_instance = new CStiLibMng();
		}
		return _instance;
	}
	void Clear()
	{
		delete this;
	}

	CStiLib* GetLib(CString name)
	{
		POSITION pos = m_ListStiLibs.GetHeadPosition();
		while (pos)
		{
			CStiLib* lib = m_ListStiLibs.GetNext(pos);
			if(lib->GetName() == name)
				return lib;
		}
		return NULL;
	}
	void AddLib(CStiLib* lib){
		m_ListStiLibs.AddTail(lib);
	}
	void RemoveLib(CString& name){
		POSITION pos = m_ListStiLibs.GetHeadPosition();
		while (pos)
		{
			CStiLib* lib = m_ListStiLibs.GetNext(pos);
			if(lib->GetName() == name)
			{
				RemoveLib(lib);
				break;
			}
		}
	}
	void RemoveLib(CStiLib* lib){
		POSITION pos = m_ListStiLibs.Find(lib);
		if (pos)
			m_ListStiLibs.RemoveAt(pos);
	}
	void EditLib(CStiLib* lib){

	}
	const CList<CStiLib*, CStiLib*>* GetLibList()
	{
		return &m_ListStiLibs;
	}

private:
	CList<CStiLib*, CStiLib*> m_ListStiLibs;
	static CStiLibMng* _instance;
};

#endif // !defined(AFX_STILIBMNG_H__1658B213_82DF_4445_9D03_572FA6C3602C__INCLUDED_)
